<!DOCTYPE html>
<html lang="en"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>已发布的委托</title>
    <link rel="stylesheet" th:href="@{/layui-v2.6.4/layui/css/layui.css}" type="text/css"/>
    <link rel="stylesheet" th:href="@{/layui-v2.6.4/layui/css/modules/code.css}" type="text/css"/>
    <script th:src="@{/js/jquery-3.5.1.min.js}"></script>
    <script charset="utf-8" th:src="@{/layui-v2.6.4/layui/layui.js}" type="text/javascript"></script>
    <script>
        layui.use('element', function () {
            var element = layui.element;
        });
    </script>
    <style>
        body {
            height: 100%;
/*
            background: linear-gradient(90deg, #C9CACB, #C9CACB, #C9CACB, #C9CACB, #C9CACB, #C9CACB, #C9CACB, #C9CACB, #C9CACB, #C9CACB, #C9CACB, #C9CACB, #C9CACB, #C9CACB);
*/
        }
    </style>
</head>
<body>
<div class="layui-fluid" >
    <div class="layui-row">
        <div class="layui-col-md12 layui-tab">
    <table class="layui-table" >
        <thead>
        <tr style="height: 40px">
            <th>Id</th>
            <th>委托类型</th>
            <th>委托内容</th>
            <th>悬赏金额</th>
            <th>接单状态</th>
            <th>开始时间</th>
            <th>结束时间</th>
            <th>是否审核</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr th:if="${EntrustsById.size() eq 0}" style="width: 100%;height:100%;text-align: center;margin: auto">
            <td colspan="9" style="width: 100%;height: 100%;">目前没有评论</td>
        </tr>
        <tr th:each="entrust : ${EntrustsById}">
            <td th:text="${entrust.entrustId}"></td>
            <td th:text="${entrust.getEntType()}"></td>
            <td th:text="${entrust.getEntData()}"></td>
            <td th:text="${entrust.getEntMoney()}"></td>
            <td th:text="${entrust.getEntPlan()}"></td>
            <td th:text="${#dates.format(entrust.getGmtCreate(), 'yyyy-MM-dd')}" ></td>
<!--             th:text="${entrust.getGmtCreate()}"-->
            <td  th:text="${#dates.format(entrust.getGmtEnd(), 'yyyy-MM-dd')}"></td>
            <td th:text="${entrust.getEntState()}"></td>
            <td><i th:onclick="del([[${entrust.entrustId}]],[[${entrust.getEntConsignor()}]]);" >删除</i>&nbsp;&nbsp;
                <i th:onclick="rev([[${entrust.entrustId}]],[[${entrust.getEntConsignor()}]]);">修改</i>
            </td>
        </tr>
        </tbody>
        <script>
            function rev(bbb,ddd) {
                layer.confirm('您确要修改吗？', {
                    btn: ['修改', '取消'] //按钮
                }, function () {
                    $.ajax({
                        url: "/revEn"
                        , type: 'get'
                        , async: false
                        , data: {
                            id:bbb
                        }
                        , success: function (str) {
                            if(str.length==2){
                                    location.assign("/toRevEn/"+bbb);
                            }else if(str==1){
                                layer.msg('修改失败,当前任务已被接单');
                            }else{
                                layer.msg('修改失败,当前任务已完成');
                            }
                        }
                    });
                })
            }
            function del(aaa,ccc) {
                layer.confirm('您确要删除吗？', {
                    btn: ['确定', '取消'] //按钮
                }, function () {
                    $.ajax({
                        url: "/del"
                        , type: 'get'
                        , async: false
                        , data: {
                            id:aaa
                        }
                        , success: function (str) {
                            if(str!="-1"){
                                layer.msg('删除成功');
                                $(window.parent.$("#Money").html('账户资产:'+ str));
                                setTimeout(function () {
                                    location.assign("/Issuedbill/"+ccc);
                                },1500);
                            }else {
                                layer.msg('删除失败,当前任务已被接单');
                            }
                        }
                    });
                })
            }
        </script>
    </table>
        </div>
    </div>
</div>
</body>
</html>